const { ccclass, property, menu, requireComponent } = cc._decorator;

@ccclass
@menu("汉化/精灵")
@requireComponent(cc.Sprite)
export default class SpriteCN extends cc.Component {

    @property({ type: cc.SpriteFrame, displayName: "汉字图片" })
    spriteFrameCN: cc.SpriteFrame = null;

    @property({ displayName: "偏移位置量" })
    offset: cc.Vec2 = cc.Vec2.ZERO;

    private theSprite: cc.Sprite = null;
    protected onLoad(): void {
        if (cc.sys.languageCode.includes("zh") == false)
            return
        this.theSprite = this.getComponent(cc.Sprite);
        if(this.theSprite.spriteFrame != this.spriteFrameCN) {
            this.theSprite.spriteFrame = this.spriteFrameCN;
        }
        this.node.setPosition(this.node.getPosition().add(this.offset));
    }
}
